"""
model.py 根据需要实现实体类
"""
from db import BaseEntity

class FormattedMessage(BaseEntity):
    def __init__(self):
        super().__init__('formatted_message')
    
    def get_msg_by_category(self, category_name):
        """
        根据类别获取格式化消息
        """
        return self.get({'category': category_name}).as_dict()

class FormattedMessageCategory(BaseEntity):
    def __init__(self):
        super().__init__('formatted_message_category')
        
    def delete_category_and_msg(self, name):
        """
        删除类别和类别下的所有消息
        """
        msgs = FormattedMessage()
        msgs.delete({'category': name})
        self.delete({'name': name})
